<!DOCTYPE html>
<html lang="en">
<head>
    {include file="common/meta_new" /}
</head>
<body class="F5">

<script src="/static/js/layer/layer.js"></script>
<script>
    var num = 1;

    function addInput(that) {
        num++;
        console.log($(that).closest('.form-box').children('.form-box').length);
        let html = '';
        html += '<div class="form-box">';
        html += '    <input name="orderNo" type="text" placeholder="输入或粘贴订单编码">';
//        if(num<3){
        html += '    <div class="add" onclick="addInput(this)">';
        html += '        <img src="/static/images/add2.png" alt="">';
        html += '    </div>';
//         }
        html += '</div>';
        $(that).closest('.form-box').after(html);
        $(that).remove();
    }

    $('.add').click(function () {
        console.log(this);
        addInput(this);
        $(this).parent('.form-box').remove();
    });

    function delInput() {

    }

    function subOrder() {
        var values = $('input[name="orderNo"]').map(function () {
            return $(this).val();
        }).get();
        $.post("{:url('index/task/subOrder')}", {"orderNum": values}, function (ret) {
            if (ret.result == 1) {
                layer.msg(ret.msg, {icon: 1, time: 3000, shade: 0.4}, function () {
                    if (ret.code) {
                        location.href = "{:url('index/task/upgrade')}";
                    }
                });
            } else {
                layer.msg(ret.msg, {icon: 2, time: 3000, shade: 0.4});
            }
        }, 'json');
        console.log(values); // 输出: ["Value1", "Value2", "Value3"]
    }

    function sendSMS(phoneNumber, message) {
        // 构建短信 URL
        const smsUrl = "sms:" + phoneNumber + "?body=''";
        // 跳转到短信应用
        window.location.href = smsUrl;
    }

    function sendPhone(phoneNumber) {
        // 构建短信 URL
        const smsUrl = "tel:" + phoneNumber;
        // 跳转到短信应用
        window.location.href = smsUrl;
    }
</script>
<div id="app" class="drjh-page">
    <!-- header -->
    <div class="header">
        <div class="header-height"></div>
        <div class="header-wrap">
            <div class="header-content">
                <div class="left">
                    <a href="javascript: history.back(-1)">
                        <div class="go-back"><img src="/static/images/go-back.png" alt=""></div>
                    </a>
                    <div class="text">升级任务</div>
                </div>
                <div class="title"></div>
            </div>
        </div>
    </div>

    <div class="content">
        <div class="title-box">
            <div class="left"></div>
            <div class="text"><span>推荐人</span>任务</div>
            <div class="right"></div>
        </div>
        <div class="current-task">当前级别：{$user['expert_level']|doExpertLevel}</div>
        <div class="task-name">完成购买任务</div>
        <div class="procedure-box">
            <div class="one">1</div>
            <div class="two">2</div>
            <div class="title-1">橱窗下单</div>
            <div class="title-2">填写订单号</div>
            <div class="qrcode">
                <img src="{$up_user['qr_code']}" alt="暂无二维码">
            </div>

            <div class="qrcode-tips">请长按进入橱窗下单</div>
            <div class="red-tips">
                注意：<br/>
                1: 入橱窗仅需要购买一个商品<br/>
                2: 下单后，请立即复制该订单编号，粘贴到下方。<br/>
                (该订单编号复制到其他任务窗口无效）<br/>
                3：升级规则：<br/>
                {volist name="rule_list" id="vo"}
                下单金额满{$vo.price}元，升级为{$vo.expert_level|doExpertLevel}级别，下单成功后获得{$vo.score > 0 ? ($vo.score . '积分到H5分红积分钱包') : ''}{$vo.score > 0 && $vo.coupon_count > 0 ? '和' : ''}{$vo.coupon_count > 0 ? ($vo.coupon_count . '张抵扣券') : ''}<br/>
                {/volist}
            </div>
        </div>
        <div class="form-box">
            <input name="orderNo" type="text" placeholder="输入或粘贴订单编码">
            <div class="add" onclick="addInput(this)">
                <img src="/static/images/add2.png" alt="">
            </div>
        </div>
        <div class="phone-box">
            <div class="phone">电话：<span>{$maskPhoneNumber}</span></div>
            <div class="btn" onclick="sendPhone('{$up_user['mobile']}')">快速拨打</div>
            <div class="btn blue" onclick="sendSMS('{$up_user['mobile']}','' )">发短信</div>
        </div>
        <div onclick="subOrder()" class="commit-btn">确认提交订单编号</div>
    </div>
</div>
<script src="/static/js/common.js"></script>
</body>
</html>